<template>
	<zh-form :transprent="true" v-model="form" inputAlign="right" :label-width="200" :margin="[0, 24]" :padding="[10,0]">
	
	<zh-card :width="620">
		<template v-slot:title>
			<view style="border-left: 10rpx solid #2f54eb;">
				<zh-text  :fontSize="36" class="text-weight-b pl-10" :label="form.frdwmc"></zh-text>
			</view >
		</template>
		<template v-slot:status>
			<tm-icon  :fontSize="42" :name="data.hiddenFlag?'tmicon-eye-slash':'tmicon-eye'" style="margin: 0 20rpx;" @tap="changeSensitive"></tm-icon>
		</template>
		<template v-slot:content>
			<zh-form-desc  field="tyxydm" placeholder="未获取到统一社会信用代码"  v-model="form.dz" label="社会信用代码"   :transprent="true"></zh-form-desc>
			<zh-form-desc  field="cxzt" placeholder="未获取到存续状态"  v-model="form.cxzt" label="存续状态"   :transprent="true"></zh-form-desc>
			<zh-form-desc  field="fddbr" placeholder="未获取到法人姓名"  v-model="form.fddbr" label="法人姓名" :transprent="true"></zh-form-desc>
			<zh-form-desc  field="frZjhm" placeholder="未获取到法人证件号码"  v-model="form.frZjhm" label="法人证件号码" :transprent="true"></zh-form-desc>
			<zh-form-desc v-if="false" field="updateTime" placeholder="空" v-model="form.updateTime" label="数据获取时间" :transprent="true"></zh-form-desc>
			<zh-sheet  :margin="[0, 20]" :round="3" v-if="props.myCheckInfo.qyCheck.dsjFlag&&!props.myCheckInfo.bmFlag&&form.schoolId" :padding="[20,20]" color="deep-orange" text>
				<zh-text >本信息由学校录入,该营业执照信息作为报名条件,只能报名学校{{form.schoolName}}，如果信息有误,请携带材料前往学校申请修改</zh-text>
			</zh-sheet>
		</template>
		<zh-message ref="messageRef" :duration="2000"></zh-message>
	</zh-card>
	</zh-form>
</template>

<script lang="ts" setup>
	import {ref, reactive, onMounted,watch} from "vue";
	const props = defineProps({
		myCheckInfo: {
		  type: Object,
		  default: () => {},
		},
		//居住证信息
		modelValue: {
		  type: Object,
		  default: () => {},
		},
		index:{
		  type: Number,
		  default: 0,
		}
	})
	
	let messageRef=ref()
	let form=ref(Object.assign({},props.modelValue))
	let oldForm=ref(Object.assign({},props.modelValue))
	// 主数据
	const data = reactive({
		//脱敏
		hiddenFlag:true,
		
	})
	const changeSensitive=()=>{
		data.hiddenFlag=!data.hiddenFlag
		enInfo()
	}
	const enInfo=()=>{
		if(data.hiddenFlag){
			form.value.fddbr=getEnName(form.value.fddbr);
			form.value.frZjhm=getEnIdcard(form.value.frZjhm);
		}else{
			form.value.fddbr=oldForm.value.fddbr;
			form.value.frZjhm=oldForm.value.frZjhm;
		}
	}
	//姓名加密
	const getEnName=(fullName:any)=>{
		if(!fullName){
			return '';
		}
		return '*'+fullName.substring(1,fullName.length)
	}
	//身份证加密
	const getEnIdcard=(idCard:any)=>{
		if(!idCard){
			return '';
		}
		let enCard = ""
		if (idCard.length===18) {
			enCard = idCard.replace(/(\w{1})\w*(\w{1})/, '$1****************$2');
		}else{
			let len=idCard.length/3
			let baseLen=idCard.length-len*2
			enCard=idCard.substring(0, len)
					
			for(var i=0;i<baseLen;i++){
				enCard=enCard+"*"
			}
			enCard=enCard+idCard.substring(len*2, idCard.length)
		}
		return enCard
	}
	
	// 初始化
	onMounted(() => {
		enInfo()
	})
	watch(
	  () => props.modelValue,
	  () => {
	    form.value=Object.assign({},props.modelValue)
	    oldForm.value=Object.assign({},props.modelValue)
		enInfo()
	  },
	  { deep: true }
	);
</script>

<style>
</style>